import 'package:flutter/material.dart';

class ValueTitleCard extends StatelessWidget {
  final String value;          // 值
  final String title;          // 标题
  final TextStyle? valueStyle;  // 值文本样式（可选）
  final TextStyle? titleStyle; // 标题文本样式（可选）
  final EdgeInsets padding;    // 内边距
  final VoidCallback? onTap;   // 点击回调
  final Color? highlightColor; // 点击高亮色

  const ValueTitleCard({
    super.key,
    required this.value,
    required this.title,
    this.valueStyle,
    this.titleStyle,
    this.padding = EdgeInsets.zero,
    this.onTap,
    this.highlightColor,
  });

  // 默认文本样式
  static const TextStyle _defaultValueStyle = TextStyle(
    fontSize: 24,
    fontWeight: FontWeight.bold,
    color: Colors.black,
    height: 1.2,
  );

  static const TextStyle _defaultTitleStyle = TextStyle(
    fontSize: 14,
    fontWeight: FontWeight.normal,
    color: Colors.grey,
    height: 1.5,
  );

  @override
  Widget build(BuildContext context) {
    final effectiveValueStyle = _defaultValueStyle.merge(valueStyle);
    final effectiveTitleStyle = _defaultTitleStyle.merge(titleStyle);

    return InkWell(
      onTap: onTap,
      highlightColor: highlightColor,
      borderRadius: BorderRadius.circular(8), // 圆角点击效果
      child: Container(
        padding: padding,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Text(
              value,
              style: effectiveValueStyle,
              textAlign: TextAlign.center,
            ),
            const SizedBox(height: 4),
            Text(
              title,
              style: effectiveTitleStyle,
              textAlign: TextAlign.center,
            ),
          ],
        ),
      ),
    );
  }
}